package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.NewsCommend;
import cn.wolfcode.trip.base.domain.PersonalMessage;
import cn.wolfcode.trip.base.mapper.PersonalMessageMapper;
import cn.wolfcode.trip.base.query.NewsQueryObject;
import cn.wolfcode.trip.base.query.PersonalMessageQueryObject;
import cn.wolfcode.trip.base.service.IPersonalMessageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PersonalMessageServiceImpl implements IPersonalMessageService {
    @Autowired
    private PersonalMessageMapper personalMessageMapper;
    @Override
    public PageInfo<PersonalMessage> queryForSenderByGetterId(PersonalMessageQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<PersonalMessage> list = personalMessageMapper.queryForSenderByGetterId(qo);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<PersonalMessage> queryForChatRecords(PersonalMessageQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<PersonalMessage> list = personalMessageMapper.queryForChatRecords(qo);
        return new PageInfo<>(list);
    }



    @Override
    public void save(PersonalMessage personalMessage) {
        personalMessage.setCreateTime(new Date());

        personalMessageMapper.insert(personalMessage);
    }

    @Override
    public PersonalMessage selectByPrimaryKey(Long id) {
       return personalMessageMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateState(PersonalMessage personalMessage) {
        personalMessageMapper.updateState(personalMessage);
    }
}
